<?php	
	//function for sqlserver
	function conn(){
		try{
			$conn = new PDO( "sqlsrv:Server=(local) ; Database = town ", "sa", "tongji", array(PDO::SQLSRV_ATTR_DIRECT_QUERY => true)); 
			return $conn;
		}catch(PDOException $e){
			die($e->getMessage());
		}
	}
	
	//function for mysql
	  // function conn(){
		  // $conn = new PDO("mysql:host=localhost;dbname=town","root","",array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET 
 // NAMES'UTF8';")); 
		  // return $conn;
	  // }
	
	function utf8togb($query){
		$query = iconv("utf-8", "gbk", $query);
		return $query;
	}
	function gbtoutf8($query){
		$query = iconv("gbk", "utf-8", $query);
		return $query;
	}
	
?>
